package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.project.bean.OrderBean;
import com.project.bean.ReturnOrder;
import com.project.mapper.IOrderMapper;
import com.project.mapper.IReturnOrderMapper;
import com.project.service.IReturnOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ReturnOrderServiceImpl implements IReturnOrderService {
      @Autowired
      private IReturnOrderMapper returnOrderMapper;
      @Autowired
      private IOrderMapper orderMapper;
      @Override
      public void updateOrderStatus(ReturnOrder order) {
            //修改订单状态
            QueryWrapper<OrderBean> orderBeanQueryWrapper=new QueryWrapper<>();
            orderBeanQueryWrapper.eq("orderNum",order.getOrderNum());
            OrderBean orderBean=orderMapper.selectOne(orderBeanQueryWrapper);
            orderBean.setOrderStatus(4);
            orderMapper.updateById(orderBean);
            //添加退货记录
            returnOrderMapper.insert(order);
      }
}
